package com.execjar;

import com.google.common.collect.Lists;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.math3.stat.StatUtils;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Fc {
    @Test
    public void test() {

        //     StatUtils.variance(values)
        ArrayList<String> strings = Lists.newArrayList("100", "2000", "300");
        List<Double> collect = strings.stream().map(NumberUtils::toDouble).collect(Collectors.toList());
        //double[] values = new double[]{72400, 94300, 95600, 94000, 94500}; 9
        //double[] values = new double[]{93850, 93850, 93850, 94350, 94000};
        double[] values = new double[]{96550, 96600, 96600, 97500, 97500};
        System.out.println(StatUtils.variance(values));

        System.out.println(StatUtils.max(values) - StatUtils.min(values));

        System.out.println("众数" + Arrays.toString(StatUtils.mode(values)));
    }


    @Test
    public void bay01() {
        ArrayList<Integer> list = Lists.newArrayList(6950, 30100, 53050, 52150, 75050, 2950, 2600, 37100, 34400, 56250, 97450, 98150, 98000, 97200);
        list.addAll(Lists.newArrayList(96600, 96600, 96600, 96600, 96550));
        list.addAll(Lists.newArrayList(96600, 96600, 96000, 97500, 93000));
        list.addAll(Lists.newArrayList(91150, 43950, 43850, 43700, 85500));
        list.addAll(Lists.newArrayList(93700, 61650, 59650, 44400));

        System.out.println(list);

        IntStream intStream = IntStream.rangeClosed(1, list.size());
        List<Integer> collect = intStream.boxed().collect(Collectors.toList());
        System.out.println(collect);

    }

    @Test
    public void bay02() {
        ArrayList<Integer> list = Lists.newArrayList(8200, 32300, 56000, 54800, 77550);
        list.addAll(Lists.newArrayList(6350, 6950, 51200, 51850, 49250));
        list.addAll(Lists.newArrayList(83350, 6500, 6250, 4750, 5300));
        list.addAll(Lists.newArrayList(5300, 5350, 5300, 5300, 5300));
        list.addAll(Lists.newArrayList(5300, 5700, 5950, 6650, 96700));
        list.addAll(Lists.newArrayList(73900, 49850, 47750, 31950, 95450));
        list.addAll(Lists.newArrayList(78300, 53500, 53450, 23100, 0));

        System.out.println(list);

        IntStream intStream = IntStream.rangeClosed(1, list.size());
        List<Integer> collect = intStream.boxed().collect(Collectors.toList());
        System.out.println(collect);

    }
}
